package StrategyMode.version6;

import java.util.Scanner;

/**
 * Created by ycq on 2018/10/17.
 * 返利收费子类，继承现金收取超类
 */
public class CashReturn extends CashSuper {

    private Double moneyCondition=0.0d;
    private Double moneyReturn=0.0d;


    /**
     * 现金收取超类的抽象方法，收取现金，参数为原价，返回为当前价
     *返利收费
     * @param money
     * @return
     */
    @Override
    public double acceptCash(Double money) {
        if(money>=moneyCondition)
            money=money-Math.floor(money/moneyCondition)*moneyReturn;
        return  money;
    }


    public CashReturn(){
        Scanner in=new Scanner(System.in);
        System.out.println("请输入满足返利的数额");
        this.moneyCondition=in.nextDouble();
        System.out.println("请输入返利的数额");
        this.moneyReturn=in.nextDouble();
    }
}
